package com.easpeed.comon.database.dao

import androidx.room.Dao
import androidx.room.Insert
import androidx.room.Query
import androidx.room.Update
import com.easpeed.comon.database.bean.CommonDataSqlBean

@Dao
interface CommonDataDao {

    @Insert
    fun insert(bean: CommonDataSqlBean)

    /**
     */
    @Update
    fun update(bean: CommonDataSqlBean): Int

    /**
     * 查询
     */
    @Query("select * from table_common t where t.loginName=:loginName and (:dataType is null or t.dataType=:dataType) order by t.createTimeMills desc LIMIT :startNum,:pageSize")
    fun queryList(
        loginName: String?,
        dataType: String?,
        startNum: Long,
        pageSize: Long,
    ): List<CommonDataSqlBean>?

    /**
     * 查询
     */
    @Query("select * from table_common t where t.createTimeMills=:createTimeMills order by t.createTimeMills desc")
    fun query(createTimeMills: Long): List<CommonDataSqlBean>?

    /**
     * 查询
     */
    @Query("select * from table_common t where t.dataType=:dataType order by t.createTimeMills desc ")
    fun queryList(dataType: String): List<CommonDataSqlBean>?

    @Query("select * from table_common ")
    fun queryList(): List<CommonDataSqlBean>?


    /**
     * 删除
     */
    @Query("Delete  from table_common  where createTimeMills<=:time")
    fun delete(time: Long): Int

}